<template>
  <div class="main">
    <!--  顶部栏  -->
    <top-bar-son></top-bar-son>
    <div class="space"></div>
    <!--  切换视角按钮  -->
    <div class="btnArea">
      <van-button type="primary" size="mini" @click="notice()" block>切换三维视角</van-button>
    </div>
    <!--  内嵌页面区域  -->
    <div class="cadIframe">
      <iframe :src="this.cadSrc" height="400" width="90%" class="iframePage"></iframe>
    </div>
    <!--  底部列表区域  -->
    <div class="list">
      <div class="item" v-for="item in this.dataList">
        <p>{{ item.title }}</p>
        <span>
          <p>【算法类型】{{item.kind}} 【B值】{{item.b_value}}</p>
          <p>【发生时间】{{item.quackTime}}</p>
          <p>【矩张量】{{item.tensor}} 【破坏类型】{{item.damageDegree}}</p>
          <p>【震级】{{item.quackGrade}} </p>
          <p>【坐标】x:{{item.x}} y:{{item.y}} z:{{item.z}}</p>
        </span>
      </div>
<!--      <div class="noData" v-if="this.isExits === false">-->
<!--        <van-empty description="当前时段暂无数据" />-->
<!--      </div>-->
    </div>
  </div>
</template>

<script>
import TopBarSon from "../components/TopBarSon";
import {Dialog, Toast} from "vant";
import {getMonitorDetData} from "../request/api/indexLoadData";
import Qs from "qs";

export default {
  name: "Monitor",
  components: {TopBarSon},
  data(){
    return{
      title:'监控',
      dataList:[],
      cadSrc:this.$store.getters.monitorAreaSwitchCadCompo
    }
  },
  methods:{
    getMonitorData(time,tableName){
      //获取前端传值参数 tableName recentValue
      const formText={
        db_table:tableName,
        recentValue: time
      }
      const formJSON = Qs.parse(formText);
      getMonitorDetData(formJSON)
          .then(response =>{
            console.log(response.data.data.length);
            this.dataList = response.data.data;
            // if (response.data.data.length>0){
            //   this.isExits = true;
            //   this.dataList = response.data.data;
            // }else {
            //   this.isExits = false;
            //   Toast.fail({
            //     message:'所选时段无数据',
            //     duration:1000
            //   })
            // }
          });
    },
    loading(){
      Toast.loading({
        message:'正在加载CAD组件',
        duration:5000
      })
    },
    notice(){
      Dialog.alert({
        title:'警告',
        message:'正在构建中'
      })
    },
    cadSrcSwitch(){
      var userArea = this.$store.state.userInfo.userArea;
      if (userArea === 'all'){
        this.cadSrc = this.$store.getters.monitorAreaSwitchCadCompo;
      }else {
        this.cadSrc = this.$store.getters.monitorAreaSwitchCadByUserArea;
      }
    }
  },
  created() {
    this.loading();
    this.getMonitorData(this.$store.state.monitorRequestData.time,this.$store.getters.monitorAreaSwitchTableName);
    this.cadSrcSwitch();
  }
}
</script>

<style scoped>
.iframePage{
  transform: translate3d(0,0,0) perspective(1px) scale(1.01);
  position: relative;
  -webkit-text-stroke: inherit;
  -webkit-font-smoothing: antialiased;
}
.space{
  height: 50px;
}
.cadIframe{
  height: 420px;
  width: 90%;
  margin: 0 auto;
  /*border: 1px solid rebeccapurple;*/
}
.list{
  /*height: 400px;*/
  width: 90%;
  margin: 0 auto;
  border: 1px solid black;
  margin-top: 10px;
}
.item{
  width: 90%;
  height: 155px;
  margin: 10px auto;
  background: lightgray;
  text-align: left;
}
p{
  margin: 0 auto;
}
</style>